﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL.DateSet.FittingTableAdapters;
using DAL;
using DAL.DateSet;
namespace BLL.Wrapper
{
    public class FittingWrapper : FittingTableAdapter
    {
        public Fitting.FittingDataTable getAll()
        {
            return GetData();
        }

        public void deleteByID(int id)
        {
            HouseDiyHelper helpper = HouseDiyHelper.GetInstance();
            string sql = " delete from Fitting where brandID = " + id.ToString();
            helpper.initOle();
            helpper.delete(sql);
        }

        public void updateARecord(Fitting.FittingRow row)
        {
            Fitting.FittingDataTable table = GetData();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (Convert.ToInt32(table.Rows[i]["fittingID"].ToString()) == row.fittingID)
                {
                    table.Rows[i]["fittingName"] = row.fittingName;
                    table.Rows[i]["fittingDesc"] = row.fittingDesc;
                    table.Rows[i]["fittingCreator"] = row.fittingCreator;
                    table.Rows[i]["fittingCreateDate"] = row.fittingCreateDate;
                    break;
                }
            }
            Update(table);
        }

        public void addARecord(Fitting.FittingRow row)
        {
            Insert(row.fittingName, row.fittingDesc, row.fittingCreator, row.fittingCreateDate);
        }
    }
}
